#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>

#define TOTAL 10000
float worker_output;
float master_output;

void *worker(void *arg)
{
	int i;

	for (i = TOTAL / 2; i < TOTAL; ++i) {
		if (i % 2 == 0)
			worker_output += 1.0 / (2 * i + 1);
		else
			worker_output -= 1.0 / (2 * i + 1);
	}
}

void master()
{
	int i;

	for (i = 0; i < TOTAL / 2; ++i) {
		if (i % 2 == 0)
			master_output += 1.0 / (2 * i + 1);
		else
			master_output -= 1.0 / (2 * i + 1);
	}
}


int main()
{
	pthread_t worker_tid;
	float total;

	pthread_create(&worker_tid, NULL, worker, NULL);
	master();
	pthread_join(worker_tid, NULL);
	total = master_output + worker_output;
	printf("master_output = %f, worker_output = %f, total = %f\n", master_output, worker_output, total);
	return 0;
}
